package com.study.scala

object SortTest {
  def main(args: Array[String]): Unit = {
//    val unSortSeq = Seq(SdrdUser("11",11,"11",11),SdrdUser("18",18,"18",18),SdrdUser("13",13,"13",13),SdrdUser("14",14,"14",14))
//    println(SdrdUser("11",11,"11",11).toString)
//    val sortSeq = unSortSeq.sortWith((user1, user2) => user1.ts < user2.ts)
//    println(unSortSeq.mkString("|"))
//    println(sortSeq.mkString("|"))

    val paths = Seq("flowai/day_id=20220618","flowai/day_id=20220615","flowai/day_id=20220620","flowai/day_id=20220618","flowai/day_id=20220610")
    println(paths.toBuffer)
    println("*"*20)
    paths.sortBy(x => x).foreach(println(_))
    println("*"*20)
    paths.sortWith((x,y) => x > y).take(10).foreach(println(_))
    println("*"*20)
    paths.sortWith((x,y) => x < y).foreach(println(_))

    val path = "/a/b/c/d=1"
    println(path.substring(0,path.lastIndexOf("/") + 1))
  }
}

case class SdrdUser(wechat_uid:String,action_id:Int,msisdn:String,ts:Long){
  override def toString: String = {
    wechat_uid +","+action_id
  }

  override def equals(obj: Any): Boolean = {
    val user = obj.asInstanceOf[SdrdUser]
    this.ts < user.ts
  }
}
